CREATE   PROCEDURE [dbo].[AddTimeEntry]
(
	@UserID int,
	@ProjectID int,
	@CategoryID int,
	@EntryDate datetime,
	@Description nvarchar(255),
	@Duration decimal(10,2),
	@OvernightStay bit
)
AS
declare @id as numeric(18,0)

INSERT INTO EntryLog
(
	Description, 
	Duration, 
	EntryDate,
	ProjectID,
	UserID,	
	CategoryID,
	OvernightStay,
	BillableHours
)
VALUES
(   
	@Description,
	@Duration,
	@EntryDate,
	@ProjectID,
	@UserID,
	@CategoryID,
	@OvernightStay,
	@Duration	
)

SELECT @id = @@Identity
SELECT @id AS EntryLogID
    
INSERT INTO EntryLogLogging
(

	EntryLogID,
	Description, 
	Duration, 
	EntryDate,
	ProjectID,
	UserID,	
	CategoryID,
	OvernightStay,
	BillableHours
)
VALUES
(   
	@id,	
	@Description,
	@Duration,
	@EntryDate,
	@ProjectID,
	@UserID,
	@CategoryID,
	@OvernightStay,
	@Duration	
)

